package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.WebUser;
import com.ruoyi.system.service.IWebUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @author wsliupan
 * @title: StatisticsController
 * @projectName qingsitang
 * @description: TODO
 * @date 2021-7-1915:16
 */
@Controller
@RequestMapping("/statistics")
public class StatisticsController extends BaseController {
    @Autowired
    private IWebUserService iWebUserService;

    @GetMapping("/1")
    public String selStatistics(ModelMap mmap) {
        return "statistics/v1";
    }

    @PostMapping("/list1")
    @ResponseBody
    public TableDataInfo list1(WebUser webUser, ModelMap mmap) {
        startPage();
        List<Map> list = iWebUserService.selStatistics(webUser);
        return getDataTable(list);
    }

    @GetMapping("/v1_detail")
    public String v1Detail(Integer serverUserId , Integer deptId,String flowName,ModelMap mmap ,String beginTime,String endTime) {
        mmap.put("serverUserId",serverUserId);
        mmap.put("deptId",deptId);
        mmap.put("flowName",flowName);
        mmap.put("beginTime",beginTime);
        mmap.put("endTime",endTime);

        return "statistics/v1_detail";
    }

    @ResponseBody
    @PostMapping("/v1_detail_list")
    public TableDataInfo v1DetailList(WebUser webUser,ModelMap mmap) {
        startPage();
        List<Map> list = iWebUserService.selStatisticsDetaiList(webUser);
        return getDataTable(list);
    }

    @PostMapping("/v1_detail_list/export")
    @ResponseBody
    public AjaxResult export(WebUser webUser)
    {
        List<Map> list = iWebUserService.selStatisticsDetaiList(webUser);
        ExcelUtil<Map> util = new ExcelUtil<Map>(Map.class);
        return util.exportExcel(list, "技师服务统计报表");
    }

    @GetMapping("/2")
    public String selStatistics2(ModelMap mmap) {
        return "statistics/v2";
    }

    @PostMapping("/list2")
    @ResponseBody
    public TableDataInfo list2(WebUser webUser, ModelMap mmap) {
        startPage();
        List<Map> list = iWebUserService.selStatistics2(webUser);
        return getDataTable(list);
    }

    @GetMapping("/v2_detail")
    public String v2Detail(Integer serverUserId , Integer deptId,String flowName,ModelMap mmap,String beginTime,String endTime) {
        mmap.put("serverUserId",serverUserId);
        mmap.put("deptId",deptId);
        mmap.put("flowName",flowName);
        mmap.put("beginTime",beginTime);
        mmap.put("endTime",endTime);

        return "statistics/v2_detail";
    }

    @ResponseBody
    @PostMapping("/v2_detail_list")
    public TableDataInfo v2DetailList(WebUser webUser,ModelMap mmap) {
        startPage();
        List<Map> list = iWebUserService.selStatistics2DetailList(webUser);
        return getDataTable(list);
    }

    @GetMapping("/3")
    public String selStatistics3(ModelMap mmap) {
        return "statistics/v3";
    }

    @PostMapping("/list3")
    @ResponseBody
    public TableDataInfo list3(WebUser webUser, ModelMap mmap) {
        startPage();
        List<Map> list = iWebUserService.selStatistics3(webUser);
        return getDataTable(list);
    }

    @GetMapping("/v3_detail")
    public String v3Detail(Integer serverUserId , Integer deptId,String recycleType,ModelMap mmap,String beginTime,String endTime) {
        mmap.put("serverUserId",serverUserId);
        mmap.put("deptId",deptId);
        mmap.put("recycleType",recycleType);
        mmap.put("beginTime",beginTime);
        mmap.put("endTime",endTime);

        return "statistics/v3_detail";
    }

    @ResponseBody
    @PostMapping("/v3_detail_list")
    public TableDataInfo v3DetailList(WebUser webUser,ModelMap mmap) {
        startPage();
        List<Map> list = iWebUserService.selStatistics3DetailList(webUser);
        return getDataTable(list);
    }

    @GetMapping("/4")
    public String selStatistics4(ModelMap mmap) {
        return "statistics/v4";
    }

    @PostMapping("/list4")
    @ResponseBody
    public TableDataInfo list4(WebUser webUser, ModelMap mmap) {
        startPage();
        List<Map> list = iWebUserService.selStatistics4(webUser);
        return getDataTable(list);
    }

}
